package com.cruise.biztest1.controller;


import com.cruise.biztest1.service.LcnDemoService;
import com.cruise.biztest2.api.pojo.entity.LcnDemo;
import com.cruise.common.web.result.Result;
import com.cruise.common.web.util.WebUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 类名：HelloController
 * 描述：TODO
 * @author cruise
 * 日期：2021/1/17 下午3:33
 * 版本：1.0
 **/

@Api(tags = "业务系统1")
@RestController
@RequestMapping("/biztest1/hello")
public class HelloController {

    @Resource
    private LcnDemoService lcnDemoService;

    @ApiOperation("测试")
    @GetMapping("/sayGoodbye")
    public Result sayGoodbye(String username){
        return Result.success(username);
    }


    @ApiOperation(value = "biztest1向客人问好")
    @GetMapping("/sayHi")
    public Result<String> sayHi(@RequestParam("name")String name){
        return Result.success("Hi:"+name+ " 的ID为: "+ WebUtils.getUserId());
    }

    @ApiOperation(value = "测试分布式事务")
    @PostMapping("/addLcnDemo")
    public Result<String> addLcnDemo(@RequestBody LcnDemo lcnDemo){
        lcnDemoService.addLcnDemo(lcnDemo);
        return Result.success();
    }

}
